package com.wangc.commons.utils;

import ma.glasnost.orika.MapperFacade;
import ma.glasnost.orika.MapperFactory;
import ma.glasnost.orika.impl.DefaultMapperFactory;

/**
 * @program: yx
 * @ClassName:DOConverter
 * @description: Bean转化工具类
 * @author: GYB
 * @create: 2020-04-23 10:24
 **/
public class DOConverter {
    private MapperFactory mapperFactory = new DefaultMapperFactory.Builder().build();
    private MapperFacade  mapper;

    private DOConverter() {
        initMapping();
    }

    private static class Holder {
        private static DOConverter INSTANCE = new DOConverter();
    }

    public static MapperFacade getInstance() {
        return Holder.INSTANCE.mapper;
    }

    private void initMapping() {
        // mapperFactory.classMap(UserVO.class, UserInfo.class).byDefault().register();
        mapper = mapperFactory.getMapperFacade();
    }
}
